package com.bawei.mvvmzonghe.respository;

import android.content.Intent;

import com.bawei.mvvmzonghe.datasource.NetDataSource;
import com.bawei.mvvmzonghe.datasource.RoomDataSource;
import com.bawei.mvvmzonghe.entity.BaseResponseEntity;
import com.bawei.mvvmzonghe.entity.GoodsEntity;
import com.bawei.mvvmzonghe.entity.CateGoryEntity;
import com.bawei.mvvmzonghe.net.Api;
import com.bawei.mvvmzonghe.net.RetrofitManager;

import java.util.List;

import androidx.core.content.IntentCompat;
import androidx.lifecycle.LiveData;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/14 09:58
 * @Description : GoodsRepository
 */
public class GoodsRepository {
    private NetDataSource mNetDataSource;
    private RoomDataSource mRoomDataSource;
    public GoodsRepository() {
        mNetDataSource = new NetDataSource();
        mRoomDataSource = new RoomDataSource();
    }
    //网络：分类
    public LiveData<BaseResponseEntity<List<CateGoryEntity>>> type(int type){
        return mNetDataSource.type(type);
    }

    //网络：商品
    public LiveData<BaseResponseEntity<GoodsEntity>> goods(int id, int page, int size){
        return mNetDataSource.goods(id,page,size);
    }

    //room：存储数据
    public void insert(List<GoodsEntity.ListBean> list){
        mRoomDataSource.insert(list);
    }
    //room 数据库查询数据
    public LiveData<List<GoodsEntity.ListBean>> getRoomGoods(){
        return mRoomDataSource.getRoomGoods();
    }
}
